package com.module.dialog;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

/**
 * 图片对话框
 * showd by dell on 2018/7/5
 */

public class ImageDialog extends BaseBuilder implements View.OnClickListener {

    ImageView ivImg; //控件
    ImageParam mImageParam;

    public ImageDialog(Context context) {
        super(context);
    }

    /**
     * 初始化控件
     */
    @Override
    public void initContentView() {
        mImageParam = new ImageParam();
        View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_image, null);
        ivImg = view.findViewById(R.id.imageView);
        setContentView(view);
    }

    @Override
    protected void connectView() {
        if (mImageParam.resId != 0) {
            ivImg.setImageResource(mImageParam.resId);
        }
    }

    @Override
    public BaseBuilder getBuilder() {
        return this;
    }


    public ImageDialog setImageUrl(String url) {
        mImageParam.url = url;
        return this;
    }

    public ImageDialog setImageRes(int resId) {
        mImageParam.resId = resId;
        return this;
    }


    public class ImageParam {
        public String url;
        public int resId;
    }
}
